package com.hopu.mcshipin.controller;

import com.hopu.mcshipin.entity.R;
import com.hopu.mcshipin.entity.User;
import com.hopu.mcshipin.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("login")
    public R login(@RequestBody User user){
        R login = userService.login(user);
        return R.ok("登录成功",login);
    }

    @PostMapping("register")
    public R register(@RequestBody User user){
        return userService.register(user);
    }

}
